﻿Billfish:
    senvim.setwin("ahk_class Qt5152QWindowIcon","ahk_class Qt5152QWindowIcon","Billfish.EXE")
    vim.SetAction("<Billfish_InsertMode>", "进入VIM模式")
    vim.SetAction("<Billfish_NormalMode>", "返回正常模式")
    vim.SetWin("Billfish","ahk_class Qt5152QWindowIcon","Billfish.exe")
    vim.BeforeActionDo("Billfish_CheckMode", "Billfish")
    ; #Include %A_ScriptDir%\plugins\Billfish\BillfishComment.ahk 
    
;normal模式
    vim.SetMode("normal", "Billfish")
    vim.Map("<insert>", "<Billfish_SwithMode>", "Billfish")
;insert模式
    vim.SetMode("insert", "Billfish")
    vim.Map("<insert>", "<Billfish_SwithMode>", "Billfish")
    vim.Map("y", "<Billfish_openDefault>", "Billfish")
    vim.Map("Y", "<Billfish_open_default_CopyPath>", "Billfish")
    vim.Map("k", "<Billfish_向下滚动>", "Billfish")
    vim.Map("j", "<Billfish_向上滚动>", "Billfish")
    ; vim.Map("k", "<Billfish_逐帧下>", "Billfish")
    ; vim.Map("g", "<Billfish_gif播放暂停>", "Billfish")
    ; vim.Map("f", "<Billfish_搜索添加>", "Billfish")
    ; vim.Map("y", "<Billfish_open_default_CopyPath>", "Billfish")
    ; vim.Map("t", "<Billfish_open_default_CopyPathToTC>", "Billfish")
    ; vim.Map(":ae", "<Billfish_打开为AfterEffect>", "Billfish")
    vim.Map("vv", "<Billfish_打开为AfterEffect>", "Billfish")
    vim.Map("vs", "<Billfish_打开为Photoshop>", "Billfish")


    
    ;载入按键
return

;   输入状时态屏蔽
Billfish_CheckMode()
{
    ControlGetFocus, ctrl, A
    If RegExMatch(ctrl,"i)Edit")
        {
            return True 
        }
    If (A_Cursor=="IBeam") 
    {
        return True
    }
    else
    {
        return false
    }
    return
}


;单键切换模式
<Billfish_SwithMode>:
        if  Billfish_var=2 ; 总
            Billfish_var=0
            Billfish_var+=1
        if (Billfish_var=1 )
        {    
            GoSub,<Billfish_NormalMode>
            return
        }
        if (Billfish_var=2)
        {
            GoSub,<Billfish_InsertMode>
            return
        }
return

;默认模式
<Billfish_NormalMode>:
    SetModUINormal()
    vim.SetMode("normal", "Billfish")
return

;进入模式
<Billfish_InsertMode>:
    SetModUIInsert()
    vim.SetMode("insert", "Billfish")
return


<Billfish_openDefault>:
		GV_KeyClickAction1 := "Gosub,<Billfish_open_default_local>"
		GV_KeyClickAction2 := "Gosub,<Billfish_open_default_CopyPathToTC>"
		GoSub,Sub_KeyClick
return

; -------------------------- 功能 -------------------------------
<Billfish_open_default_local>:
	send,{RButton}
	Sleep,100
	WinActivate ahk_class Qt5152QWindowPopupDropShadowSaveBits
	CoordWinClick(52,30)
return
<Billfish_open_default_Path>:
	send,{RButton}
	Sleep,100
	WinActivate ahk_class Qt5152QWindowPopupDropShadowSaveBits
	CoordWinClick(54,59)
return
<Billfish_open_default_CopyPath>:
	send,{RButton}
	Sleep,100
    ; MyWinWaitActive("Qt5152QWindowPopupDropShadowSaveBits")
	WinActivate ahk_class Qt5152QWindowPopupDropShadowSaveBits
    send,{Down 4}
    Sleep,100
	; CoordWinClick(63,133)
	; Sleep,1000w
	send,{right}
	Sleep,100
	send,{Up 2}{Enter}
    Sleep,400
    ToolTip 已复制：%Clipboard%
    Sleep,800
	SetTimer, ToolTipOff, -6000
return

<Billfish_open_default_CopyPathToTC>:
	Gosub,<Billfish_open_default_CopyPath>
	ControlGetText, OutputVar, Edit1, A
	sleep 100
	DiagPath := % Clipboard
	WinActivate ahk_class TTOTAL_CMD
	PostMessage 1075, 3001, 0, , AHK_CLASS TTOTAL_CMD
	ControlSetText, Edit1, cd %DiagPath%, ahk_class TTOTAL_CMD
	Sleep 400
	ControlSend, Edit1, {Enter}, ahk_class TTOTAL_CMD
    Sleep 400
    MyWinWaitActive("ahk_class TTOTAL_CMD")
return

<Billfish_向下滚动>:
sendinput,{WheelDown}
return
<Billfish_向上滚动>:
sendinput,{WheelUp}
return

<Billfish_拷贝路径>:
Gosub,<Billfish_open_default_CopyPath>
return

<Billfish_打开路径>:
Gosub,<Billfish_open_default_Path>
return

<Billfish_打开路径为TC>:
Gosub,<Billfish_open_default_CopyPathToTC>
return

<Billfish_复制路径>:
Gosub,<Billfish_open_default_CopyPathToTC>
return
<Billfish_打开为Photoshop>:
	send,{RButton}
	Sleep,100
	WinActivate ahk_class Qt5152QWindowPopupDropShadowSaveBits
    send,{Down 4}
    Sleep,100
	send,{right}
	Sleep,100
	send,{Up 2}{Enter}
    Sleep,100
    ToolTip 正在打开：%Clipboard%
    Sleep,300
	SetTimer, ToolTipOff, -6000
    Run,"C:\Program Files\Adobe\Adobe Photoshop 2022\Photoshop.exe" %Clipboard%
    MyWinWaitActive("ahk_exe Photoshop.exe")
return
<Billfish_打开为AfterEffect>:
	send,{RButton}
	Sleep,100
	WinActivate ahk_class Qt5152QWindowPopupDropShadowSaveBits
    send,{Down 4}
    Sleep,100
	send,{right}
	Sleep,100
	send,{Up 2}{Enter}
    Sleep,100
    ToolTip 正在打开：%Clipboard%
    Sleep,300
	SetTimer, ToolTipOff, -6000
    Run,"C:\Program Files\Adobe\Adobe After Effects 2022\Support Files\AfterFX.exe" %Clipboard%
    MyWinWaitActive("ahk_exe AfterFX.exe")
return